Release 10.1A: OpenEdge Development:
Progress Dynamics Basic Development
Updates through the SBO
The business logic of the SBO is additive. That is, you can keep basic logic affecting only one table in each individual SDO as now. If you must add validation or other logic at the level of the SBO, it will have access to the update temp-tables for all of its contained SDOs. This enables the SBO
pre/post/begin/endTransactionValidateprocedures to use the RowObjUpd temp-tables from the different SDOs, map them to meaningful local temp-table names, and write normal (static) Progress 4GL logic against those tables. As described earlier, you can give a logical name to each SDO you drop onto it. This is theObjectNameproperty, which is initialized to the simple filename of the SDO, without the extension. You can change this instance property as needed to give the SDO a distinctive name within this SBO.This renaming might be necessary, for example, if the same SDO appears more than once in the tree, which occurs frequently in real-world applications. An Item SDO, for example, might need to be named
Itemin one instance andAlternateItemin another instance, if that is how it is used within the SBO.This property is then attached to a reference to the SDO temp-table include file. For example, the Order/OrderLine SBO can use the default SDO
ObjectNamesthat will result in AppBuilder code generation to name its update tablesorderfulloandorderlinfullo.Transaction logic in the SBO
The transaction logic is also parallel to and augments the logic of the SDO. The SBO defines an encompassing transaction within which the data from individual SDOs is committed to the database. As with SDOs, if the
Note: If the Save is against a SmartDataViewer that updates fields from multiple SDOs, then it is possible that a single Save operation could update more than one database record.AutoCommitproperty is true (which will be the default if there is noCommit-Source), then each individual Save operation results in one set of changes being committed to the database.If the
AutoCommitproperty is false (which is the default if there is aCommit-Source), then the SBO can accumulate multiple updates on the client to be sent back to the server together. This would be considered the norm for SBO usage, since SBOs are primarily intended for use in situations where rows from multiple different SDOs must be committed as part of the same transaction. The exception to this is where two or more records related on a one-to-one basis are updated through an SBO. In this case, you do not need the Commit operation, and you can setAutoCommittoTRUE. Each save request invokessubmitRowin the appropriate SDO.These changes are stored on the client until a commit occurs. When Commit is chosen, or if
AutoCommitisTRUE, the following sequence of events takes place:
- The
CommitTransactionprocedure is run in the client SBO. This procedure collects all theRowObjUpdtables from any modified SDOs on the client and passes them to the server-side SBO. It runsserverCommitTransactionin the AppServer SBO, which in turn copies the tables to their respective SDOs.- The server-side SBO executes code similar to the following block of pseudo-code. An error detected at any point results in the commit being rolled back and the error message being returned to the client, as shown in the following example:
The
pushTableAndValidateprocedure referenced in this code tells the SDO being called whether this is pre- or post-transaction validation, and passes the SDO’sRowObjUpdtable to it. This runspre/postTransactionValidatein the SDO, and then returns theTEMP-TABLEback to the SBO in case it has changed. When commit is executed in the SDO, SDO code suppresses runningpre/postTransactionValidatein the SDO if it is inside an SBO. It is run at the proper time from the SBO (to allow allpreTransactionValidatesto happen together, followed by the transaction, followed by allpostTransactionValidates).The
pre/begin/end/postTransactionValidateprocedure names are the same as the standard validation procedure hooks supported for SDOs. The SBO logic extends the logic of the SDOs without introducing new naming conventions. The additional validation logic entry points that are available for use with the Progress Dynamics SDO’s logic procedure (createPreTransValidate, etc.) are not defined for SBOs.This nested form allows maximum flexibility in the location of SBO logic and the coordination of that logic with SDO logic. The
pushTableAndValidateprocedure (implemented indata.ito allow it to use the static SDO temp-table as a parameter) assures that changes are automatically shared between the SBO and its SDOs. The cost of organizing the code in this way is not as great as it might seem at first.pushTableAndValidatewill not be executed except where validation procedures exist in the individual SDOs. It is important to let you control the placement of logic at each stage (pre/begin/end/post), and also at the appropriate place within each stage. The SBO can add its own logic at the very beginning of all logic, at the beginning of the transaction, at the very end of the transaction, and at the very end of all the logic (after all the SDOs’postTransactionValidateprocedures). Or a given SBO could completely replace theserverCommitTransactionprocedure if necessary to control the logic in a special way. (Note that this procedure is defined insbo.i, to receive theRowObjUpdtemp-tables into the SBO’s definition of them, so you cannot override it, only replace it.)The most common form of business logic that spans SDOs, namely assigning key values to new records, is handled automatically by the SBO support code in the
serverCommitTransactionprocedure. If you are adding rows to both a parent and child SDO in the same transaction, thenForeignFieldvalues are retrieved from the parent record after it has been written to the database and assigned to each of the child records. This is similar to the way in which key values are assigned to new records added through an SDO with aData-Source. The difference is that the supporting code in the SBO allows both parent and child records to be added in the same transaction. All newly assigned values will be passed back to the client for display, as with any other changes made on the server-side.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |